﻿using System.Collections.Concurrent;
using System.Collections.Generic;
using RayDen.RayEngine.Core.Interface;

namespace RayDen.RayEngine.Core.Types
{
    public class OutputRayBufferCollection<TRayBuffer>
        where TRayBuffer : IRayBufferBase
    {
        private readonly List<BlockingCollection<TRayBuffer>> doneBuffers;
        public int Count
        {
            get { return doneBuffers.Count; }
        }

        public OutputRayBufferCollection()
        {
            doneBuffers = new List<BlockingCollection<TRayBuffer>>(10) { new BlockingCollection<TRayBuffer>(new ConcurrentBag<TRayBuffer>()) };
        }

        public void AddBuffer()
        {
            doneBuffers.Add(new BlockingCollection<TRayBuffer>(new ConcurrentBag<TRayBuffer>()));
        }


        public void Put(int index, TRayBuffer rb)
        {
            doneBuffers[index].Add(rb);
        }




        public TRayBuffer Get(int info)
        {
            //RayBuffer rb;
            return doneBuffers[info].Take();
            //return rb;
        }
    }


    public class OutputRayBufferCollection : OutputRayBufferCollection<RayBuffer>
    {

    }
}